Análise de um database de vendas¶

Bibliotecas¶

In [1]:
import pandas as pd
import plotly_express as px
C:\Users\Administrador\AppData\Local\Temp\ipykernel_8420\2416028524.py:1: DeprecationWarning: 
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
        
  import pandas as pd

Database¶

In [2]:
vendas = pd.read_excel('vendas.xlsx')
In [3]:
vendas.head()
Out[3]:
id_pedido data loja cidade estado regiao tamanho local_consumo preco forma_pagamento ano_mes
0 PED1994 2020-01-01 Loja 4 Santos São Paulo Sudeste 300ml Consumo no local 5 Dinheiro 2020-01
1 PED2246 2020-01-01 Loja 6 Florianópolis Santa Catarina Sul 500ml Consumo no local 11 Débito 2020-01
2 PED3876 2020-01-01 Loja 3 Rio de Janeiro Rio de Janeiro Sudeste 300ml Delivery 7 Crédito 2020-01
3 PED4352 2020-01-01 Loja 1 Fortaleza Ceará Nordeste 1000ml Consumo no local 7 Débito 2020-01
4 PED8633 2020-01-01 Loja 5 São Paulo São Paulo Sudeste 200ml Delivery 9 Crédito 2020-01

Visualizações¶

Códigos¶

In [4]:
#Gráfico de faturamento por loja

fig1 = px.histogram(vendas, 
                   x="loja",
                   y= "preco",
                   color="regiao", 
                   text_auto = "True" , 
                   width=800,
                   height=600,
                   title='Faturamento por Loja',
                   labels={'regiao': 'Região','loja':'Loja'},
                   category_orders=dict(loja=["Loja 1", "Loja 2", "Loja 3", "Loja 4", "Loja 5", "Loja 6"])
                  )

faturamento_loja = fig1.update_layout(yaxis_title='Total de Faturamento')


#Grafico faturamento por tamanho

fig2 = px.histogram(vendas,
                   x="tamanho", 
                   y="preco",
                   width = 800,
                    color = 'tamanho',
                   height = 600,
                   category_orders=dict(tamanho=["200ml", "300ml", "500ml", "700ml", "1000ml"]), 
                   title = 'Faturamento por tamanho', 
                   labels={'tamanho': 'Tamanho'},
                   text_auto = "True" 
                  )

faturamento_tamanho = fig2.update_layout(yaxis_title = 'Faturamento')


#Gráfico formas de pagamento

formas_pagamento = px.pie(vendas,
            names = 'forma_pagamento',
            title = 'Formas de pagamento mais usadas',
            width=700, 
            height=700
            )


#Gráfico locais de consumo



locais_consumo = px.pie(vendas,
            names = 'local_consumo',
            title = 'Local de consumo',
            width=700, 
            height=700
            )


#Gráfico vendas por período 

venda_periodo = vendas['data'].value_counts().sort_index()
venda_periodo1 = venda_periodo.reset_index()
vendas_periodo2 = px.line(venda_periodo1,
               x = 'data',
               y='count'
              )
C:\Users\Administrador\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotly\express\_core.py:2065: FutureWarning: When grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass `(name,)` instead of `name` to silence this warning.
  sf: grouped.get_group(s if len(s) > 1 else s[0])
C:\Users\Administrador\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotly\express\_core.py:2065: FutureWarning:

When grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass `(name,)` instead of `name` to silence this warning.

Gráficos¶

In [5]:
vendas_periodo2
In [6]:
faturamento_loja
In [7]:
faturamento_tamanho
In [8]:
formas_pagamento
In [9]:
locais_consumo
In [ ]: